import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:ytbusiness/state/user_role.dart';
import 'package:ytbusiness/utils/helper.dart';
import 'package:ytbusiness/utils/screen_adaptation.dart';
import 'package:ytbusiness/widgets/widgets.dart';

//我的店铺
class MyStore extends StatefulWidget {
  @override
  _MyStoreState createState() => _MyStoreState();
}

class _MyStoreState extends State<MyStore> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: customAppBar(context, title: "我的店铺"),
      body: ListView(
        children: [
          _item("企业名片", voidBack: () {
            urlPush(context, "yuntu://modify_store");
          }),
          _item("企业认证", voidBack: () {
            urlPush(context, "yuntu://modify_perfect");
          }),
          _item("经营信息", voidBack: () {
            switch (Provider.of<UserRole>(context, listen: false).role) {
              case 1:
                urlPush(context, "yuntu://modify_store_manage_info");
                break;
              case 2:
                urlPush(context, "yuntu://modify_manage_info");
                break;
            }
          }),
        ],
      ),
    );
  }

  Widget _item(String title, {Function voidBack}) {
    return GestureDetector(
      behavior: HitTestBehavior.opaque,
      onTap: () => voidBack(),
      child: Container(
        padding: EdgeInsets.only(left: setWidth(15), right: setWidth(15)),
        margin: EdgeInsets.only(top: setWidth(15)),
        height: setWidth(60),
        color: Colors.white,
        child: Row(
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          children: [
            Container(
              child: Text(
                title,
                style: TextStyle(color: Color(0xff323232), fontSize: setSp(15)),
                maxLines: 1,
                overflow: TextOverflow.ellipsis,
              ),
            ),
            Container(
              width: setWidth(9),
              height: setWidth(14),
              child: Image.asset(
                "assets/images/right_go.png",
                fit: BoxFit.cover,
              ),
            )
          ],
        ),
      ),
    );
  }
}
